<%@ page import="java.util.HashMap,common.CommonUtil,java.util.*,common.*" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/commontags.tld" prefix="common" %><%--페이징처리tag--%>
<%
UserSession userSession = (UserSession)session.getAttribute("user"); 

String login_id = null;
String user_id = null;
String level = null;

if(userSession!= null){
	login_id = userSession.getLogin_id();
	user_id = userSession.getUser_id();
	level = userSession.getAdmin_level();
}

String gubun	= CommonUtil.nvl(request.getParameter("gubun"),"OPIC"); 
String start_date	= CommonUtil.nvl(request.getParameter("start_date"),""); 
String end_date	= CommonUtil.nvl(request.getParameter("end_date"),"");

if(gubun.equals("")){
	gubun = "OPIC";
}

HashMap listMap=(HashMap)request.getAttribute("list_map");

HashMap map  = null;
ArrayList list=null;

HashMap map_1  = null;
ArrayList list_1=null;

String rater_id 	= "";
String rater_name 	= "";
String per_cnt	= "0";


String rater_cnt = "0";
String ready = "0";
String progress = "0";
String end = "0";
String holding = "0";

String s_total_cnt	= "0";

String v_start_date	= ""; 
String v_end_date	= "";

if (listMap!=null){
    list=(ArrayList)listMap.get("mainContent");
}

if(list != null){
	if(list.size() > 0){
		s_total_cnt = CommonUtil.nvl((String)((HashMap)list.get(0)).get("s_total_cnt"),"0");
		v_start_date = CommonUtil.nvl((String)((HashMap)list.get(0)).get("v_start_date"),"");
		v_end_date = CommonUtil.nvl((String)((HashMap)list.get(0)).get("v_end_date"),"");
	}
}

if(v_start_date.equals("")){
	v_start_date = CommonUtil.getToday("yyyy")+"-"+CommonUtil.getToday("MM")+"-"+CommonUtil.getToday("dd");
	v_end_date = CommonUtil.getToday("yyyy")+"-"+CommonUtil.getToday("MM")+"-"+CommonUtil.getToday("dd");
}

if(start_date.equals("")){
	start_date = v_start_date;
}

if(end_date.equals("")){
	end_date = v_end_date;
}

String[] start_date_arr = start_date.split("-");
String[] end_date_arr = end_date.split("-");
%>
<jsp:include page="/jsp/common/header.jsp"></jsp:include>
<script language='javascript' src="/js/calendar.js"></script>
<script language='javascript' src="/js/ajaxutil.js"></script>
<script>


//검색
function go_search(){
	var frm = document.mainform;
	
	var start_date_arr = frm.start_date.value.split('-');
	var s_year = start_date_arr[0];
	var s_month = Lpad(start_date_arr[1], 2);
	var s_day = Lpad(start_date_arr[2], 2);
	
	frm.start_date.value = s_year+'-'+s_month+'-'+s_day;
	
	var end_date_arr = frm.end_date.value.split('-');
	var e_year = end_date_arr[0];
	var e_month = Lpad(end_date_arr[1], 2);
	var e_day = Lpad(end_date_arr[2], 2);
	
	frm.end_date.value = e_year+'-'+e_month+'-'+e_day;
	
	frm.cmd.value='statistics_rater';
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}

function go_excel(){
	var frm = document.mainform;
	
	var start_date_arr = frm.start_date.value.split('-');
	var s_year = start_date_arr[0];
	var s_month = Lpad(start_date_arr[1], 2);
	var s_day = Lpad(start_date_arr[2], 2);
	
	frm.start_date.value = s_year+'-'+s_month+'-'+s_day;
	
	var end_date_arr = frm.end_date.value.split('-');
	var e_year = end_date_arr[0];
	var e_month = Lpad(end_date_arr[1], 2);
	var e_day = Lpad(end_date_arr[2], 2);
	
	frm.end_date.value = e_year+'-'+e_month+'-'+e_day;
	
	frm.cmd.value='statistics_rater_excel';
	frm.action = "/speaking.pb";
	frm.target="_self";
	frm.submit();
}


</script>

<jsp:include page="/jsp/common/top.jsp"></jsp:include>

<jsp:include page="/jsp/common/submenu.jsp"><jsp:param name="submenu_id" value="statistics_opic" /><jsp:param name="submenu_idx" value="6" /></jsp:include>

<form name="mainform"  method="post" action = "/speaking.pb" >
	<div id="bodyContainer">
        <div id="contents">
          
          <div class="select_menu3">
            <ul>
              <li>  시작일 : <INPUT TYPE="text" NAME="start_date"  id="start_date" value="<%=start_date %>" OnFocus=cal(<%=start_date_arr[0] %>,<%=start_date_arr[1] %>,<%=start_date_arr[2] %>,this);></li>
              
              <li class="mt5">~</li>
              <li>종료일 : <INPUT TYPE="text" NAME="end_date"  id="end_date" value="<%=end_date %>" OnFocus=cal(<%=end_date_arr[0] %>,<%=end_date_arr[1] %>,<%=end_date_arr[2] %>,this);></li>
              
              <li>
              	<select name="gubun" id="gubun" style="width:100px">
                  <option value=''>시험구분</option>
                  <option value='OPIC' <%=(gubun.equals("OPIC")?"selected":"") %>>OPIC</option>
                  <option value='TS' <%=(gubun.equals("TS")?"selected":"") %>>T/S</option>
                </select>
              </li>
              <li><a href="#" onclick="go_search()"><img src="img/btn_search.gif" alt="search" /></a></li>
              
              <li><a href="#" onclick="go_excel()"><img src="img/btn_excel.gif" alt="excel" /></a></li>
            </ul>
          </div>
          
          <div class="boxContainer">
          <B>전체 시험완료 횟수 : <%=s_total_cnt %></B> 
            <table class="graphTb">
              <tr>
                <th width="120">Rater</th>
                <th >그래프</th>
                <th>할당횟수</th>
                <th>Ready</th>
                <th>Progress</th>
                <th>End</th>
                <th>Holding</th>
              </tr>
<%               

    if (list!=null && list.size()> 0) {
    	for(int i=0; i<list.size(); i++){
	      map=(HashMap)list.get(i);
	      rater_id = CommonUtil.nvl((String)map.get("rater_id"));
	      rater_name = CommonUtil.nvl((String)map.get("rater_name"));
	      per_cnt = CommonUtil.nvl((String)map.get("per_cnt"));
	      rater_cnt = CommonUtil.nvl((String)map.get("rater_cnt"));
	      ready = CommonUtil.nvl((String)map.get("ready"));
	      progress = CommonUtil.nvl((String)map.get("progress"));
	      end = CommonUtil.nvl((String)map.get("end"));
	      holding = CommonUtil.nvl((String)map.get("holding"));
%>
			  <tr>
                <td><%=rater_name %></td>
                <td class="bar"><img src="img/bg_bar02.gif" alt="그래프바" width="<%=per_cnt%>%" height="10" /><br />
                  <%=per_cnt%>%</td>
                <td><%=rater_cnt %></td>
                <td><%=ready %></td>
                <td><%=progress %></td>
                <td><%=end %></td>
                <td><%=holding %></td>
              </tr>
<%	      
    	}
    }else{
%>
              <tr>
                <td colspan=8 align=center>할당 된  자료가 없습니다.</td>
              </tr>
<%} %>              
              
            </table>            
          </div>
          
        </div>
      </div>


<input type="hidden" name="cmd" value="">
<input type="hidden" name="user_id" value="<%=user_id %>">

</form>

<iframe name='hidden_frm'  width='0' height='0' SCROLLING='AUTO' frameborder='0'></iframe>
<jsp:include page="/jsp/common/footer.jsp"></jsp:include>
<jsp:include page="/jsp/common/bottom.jsp"></jsp:include>
